Skip to content

Harden v0.6 sensors, readiness tracking, platform toggles, validation, and blueprints - #331

Merged
binarydev merged 2 commits into
mainfrom
fix/v06-hardening
Nov 21, 2026
Merged

binarydev merged 2 commits into
mainfrom
fix/v06-hardening

Conversation

@binarydev

Copy link
Copy Markdown
Owner

Summary

Addresses post-merge review findings from v0.6 feature PRs (#327, #328, #329) ahead of the v0.6.0 release:

  • Prevent Long-Term Statistics reset spikes & zero-dip artifacts: Return None (unknown) instead of 0 when generator/propane/weather properties are missing on RunTimeSensor, ProtectionTimeSensor, BatteryVoltageSensor, OutdoorTemperatureSensor, CapacitySensor, and WeatherSensor.native_temperature, while preserving explicit 0 readings from the API.
  • Harden ReadinessTracker:
    • Guard async_load() with an asyncio.Lock and mark loaded only after storage reads complete.
    • Keep service_baseline_hours unset (None) until the first valid run_time arrives (and heal legacy beta store records with last_run_time: None and service_baseline_hours: 0.0) to prevent false Day-1 maintenance alerts.
    • Ignore transient drops to 0.0 in both async_update_from_items() and async_reset_service_timer() when a positive last_run_time is already recorded so missed-exercise and maintenance timers aren't corrupted.
  • Honor Options platform toggles: Filter platform setup using entry.options (_enabled_platforms, safely defaulting non-boolean option values to True) and track coordinator.loaded_platforms so unloading/reloading toggles platforms cleanly.
  • Fix propane monitor maintenance_due Repairs alerts: Restrict Mobile Link hasMaintenanceAlert Repairs alerts to generators so propane tank monitors do not surface generator-specific reset prompts.
  • Enforce UI option bounds & defensive parsing: Add shared safe_int_option and safe_float_option helpers across coordinator, readiness, and Repairs evaluation; enforce >= 10 s polling intervals in Options and Reconfigure; cap float options so non-finite floats (NaN/inf) are rejected while Voluptuous schemas remain serializable for the Home Assistant UI.
  • Adaptive polling refinement: Remove Stopped (5) from _ACTIVE_GENERATOR_STATUSES in coordinator.py and README.md so switched-off generators return to idle polling instead of locking at the active interval.
  • Harden & connect bundled blueprints:
    • generac_outage_load_shedding.yaml: Normalize single-string shed_entities, capture pre-outage active loads before shedding so already-off loads aren't turned on, and switch to mode: single with a repeat / wait_for_trigger loop so mid-outage status flaps (Running → Warning → Running) re-shed loads without wiping entities_to_restore.
    • generac_fault_dealer_alert.yaml: Add optional error_code_sensor (default: null) and format notifications with |- + Jinja trimming for clean line breaks.
    • generac_storm_readiness_digest.yaml: Switch optional fuel_level_sensor default to null, add optional remaining_fuel_sensor and estimated_runtime_sensor inputs, and format notifications cleanly across lines with |-.

Testing

  • pytest -v --no-cov: 180/180 passed (including new regression tests for missing-property None behavior, ReadinessTracker edge cases & concurrency, platform toggle reloads, propane Repairs gating, Options/Reconfigure schema bounds & voluptuous_serialize UI compatibility, Stopped polling status, and end-to-end Home Assistant runtime execution of all 3 blueprints).
  • pre-commit run --all-files: All 8 hooks passed (check-added-large-files, check-yaml, end-of-file-fixer, trailing-whitespace, flake8, reorder-python-imports, black, prettier).

@binarydev
binarydev merged commit e90e52e into main Nov 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant